Skip to content

Fix Swift 6 async let actor isolation crash#67

Merged
christopherkarani merged 2 commits intochristopherkarani:mainfrom
NickTrienens2025:fix/async-let-crash
May 5, 2026
Merged

Fix Swift 6 async let actor isolation crash#67
christopherkarani merged 2 commits intochristopherkarani:mainfrom
NickTrienens2025:fix/async-let-crash

Conversation

@NickTrienens2025
Copy link
Copy Markdown
Contributor

Replaces async let calls to actor-isolated methods with sequential awaits to fix a known compiler bug on macOS ARM64 that causes a swift_task_dealloc heap corruption. The async let task lowering in Swift 6 occasionally triggers a double-free of the task context when capturing self on an actor. Moving to sequential await avoids the compiler miscompilation.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 93ece0a935

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +79 to +83
let surrogateMapTask: [UInt64: UInt64] = shouldPrefetchSurrogates
? try await wax.surrogateFrameIds(for: sourceFrameIds)
: [:]
async let sourceFrameMetasTask: [UInt64: FrameMeta] = shouldPrefetchSurrogates
? wax.frameMetas(frameIds: sourceFrameIds)
let sourceFrameMetasTask: [UInt64: FrameMeta] = shouldPrefetchSurrogates
? try await wax.frameMetas(frameIds: sourceFrameIds)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid blocking expansion on surrogate prefetch calls

These two immediate awaits run before expansion starts, so every denseCached request now pays for surrogateFrameIds + frameMetas on the critical path even when surrogate assembly is later skipped (for example, when expansion consumes the token budget). In the previous version this work was overlapped with expansion via async let; here it is fully serialized, which introduces avoidable latency in the common path. Keep the async-let workaround, but move these awaits into the surrogate phase (after expansion determines surrogates are still needed) to avoid front-loading this I/O.

Useful? React with 👍 / 👎.

@christopherkarani christopherkarani merged commit d658cfa into christopherkarani:main May 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants